﻿namespace KinonekoSoftware.Studio.Resources.Converters
{
    public class SponsorConverter : IValueConverter
    {
        private static readonly ImageSource Sponsor1 = new BitmapImage(new Uri("pack://application:,,,/KinonekoSoftware.Studio.Views;component/Resources/Images/sponsor_1.png"));
        private static readonly ImageSource Sponsor2 = new BitmapImage(new Uri("pack://application:,,,/KinonekoSoftware.Studio.Views;component/Resources/Images/sponsor_2.png"));
        private static readonly ImageSource Sponsor3 = new BitmapImage(new Uri("pack://application:,,,/KinonekoSoftware.Studio.Views;component/Resources/Images/sponsor_3.png"));
        private static readonly ImageSource Sponsor4 = new BitmapImage(new Uri("pack://application:,,,/KinonekoSoftware.Studio.Views;component/Resources/Images/sponsor_4.png"));

        private static int _index;
        
        public object Convert(object value, Type targetType, object parameter, CultureInfo culture)
        {
            _index++;
            var i = _index % 4;
            return i switch
            {
                1 => Sponsor2,
                2 => Sponsor3,
                3 => Sponsor4,
                _ => Sponsor1,
            };
        }
        
        public object ConvertBack(object value, Type targetType, object parameter, CultureInfo culture)
        {
            throw new NotSupportedException();
        }
    }
}